<template>
  <div class="view-fill">
    <div
      v-if="!modifyInfo.visible"
      class="app-container-flex"
      v-show="
        !purchOrderCheckApplicationInfo.visible && !templateModifyInfo.visible
      "
    >
      <NewFullScreen
        v-model="showDialog"
        title="申购单明细"
        :btn-list="fullInfo.btnList"
        :needOperateAffair="true"
        :operateAffairData="affairTableInfo"
        @returnBack="returnBack"
      >
        <template v-slot:full-button>
          <el-button v-if="canUpdate" @click="update">修改</el-button>

          <PopoverPrint
            ref="popoverShow"
            v-model:popoverVisible="popoverVisible"
            :canPrint="canPrint"
            :templateArr="templateArr"
            @tempClick="tempClick"
            @print="print"
          ></PopoverPrint>

          <!-- <el-popover
            v-model:visible="popoverVisible"
            placement="bottom"
            :width="160"
            popper-class="popoverBox"
            trigger="click"
          >
            <template #reference>
              <el-button v-if="canPrint" @click="print">打印</el-button>
            </template>
            <div v-if="templateArr && templateArr.length > 1" class="selectBox">
              <span
                v-for="item in templateArr"
                :key="item.id"
                :title="item.tplName"
                @click="tempClick(item)"
                class="col"
                >{{ item.tplName }}</span
              >
            </div>
          </el-popover> -->
          <!-- <el-button v-if="canPrint" @click="print">打印</el-button> -->
          <el-button v-if="canExcel" @click="exportExcel">导出excel</el-button>

          <el-button v-if="submit" @click="handleClick('submit')"
            >提交
          </el-button>
          <el-button v-if="revoke" @click="handleClick('revoke')"
            >撤回
          </el-button>
          <el-button v-if="ratify" @click="handleClick('ratify')"
            >批准
          </el-button>
          <el-button v-if="review" @click="handleClick('review')"
            >复核
          </el-button>
          <el-button v-if="canReturn" @click="handleClick('return')"
            >退回
          </el-button>
          <el-button v-if="canReject" @click="handleClick('reject')"
            >驳回
          </el-button>
          <el-button v-if="canSplit" @click="handleClick('split')"
            >拆单
          </el-button>
          <el-button v-if="stop" @click="handleClick('stop')">中止</el-button>
          <el-button
            v-if="
              $permission('purchApplication:generate') &&
              (infoList.data.status === 5 || infoList.data.status === 3)
            "
            @click="handelGeneratePurch"
            >生成采购单
          </el-button>
          <el-button
            v-if="$permission('purchApplication:saveCopeTemplate')"
            @click="saveCopeTemplate"
            >另存为模板
          </el-button>
          <el-button
            v-if="$permission('purchApplication:copy')"
            @click="copyApplicationOrder"
            >拷贝
          </el-button>
        </template>

        <div class="model-panel">
          <div class="model-panel-title">
            <p>{{ $t('basic_information') }}</p>
          </div>
          <div class="model-panel-body">
            <basic-information :info="infoList">
              <template v-slot:basic-mergedOrders>
                <span
                  v-if="
                    infoList.data.mergedOrders &&
                    infoList.data.mergedOrders.length <= 3
                  "
                >
                  <span
                    v-for="(item, itemIndex) in infoList.data.mergedOrders"
                    :key="itemIndex"
                  >
                    <a class="slip-edit" @click="getNew(item.id)">{{
                      item.orderNo
                    }}</a>
                    <span
                      v-if="itemIndex < infoList.data.mergedOrders.length - 1"
                      >,</span
                    >
                  </span>
                </span>
                <span
                  v-if="
                    infoList.data.mergedOrders &&
                    infoList.data.mergedOrders.length > 3
                  "
                >
                  <span
                    v-for="(
                      item, itemIndex
                    ) in infoList.data.mergedOrders.slice(0, 2)"
                    :key="itemIndex"
                  >
                    <a class="slip-edit" @click="getNew(item.id)">{{
                      item.orderNo
                    }}</a>
                    <span v-if="itemIndex < 1">,</span>
                  </span>
                  <el-dropdown @command="handleCommand">
                    <span class="el-dropdown-link slip-edit">
                      更多<i class="el-icon-arrow-down el-icon--right"></i>
                    </span>
                    <template #dropdown>
                      <el-dropdown-menu>
                        <el-dropdown-item
                          v-for="(
                            item, index
                          ) in infoList.data.mergedOrders.slice(
                            2,
                            infoList.data.mergedOrders.length
                          )"
                          :key="index"
                          :command="item.id"
                          >{{ item.orderNo }}
                        </el-dropdown-item>
                      </el-dropdown-menu>
                    </template>
                  </el-dropdown>
                </span>
              </template>
              <template v-slot:basic-mergedOrder>
                <a
                  v-if="infoList.data.mergeOrder"
                  class="slip-edit"
                  @click="getNew(infoList.data.mergeOrder.id)"
                  >{{ infoList.data.mergeOrder.orderNo }}</a
                >
              </template>
            </basic-information>
          </div>
        </div>
        <div class="model-panel">
          <div class="model-panel-title">
            <Tooltip :text="$t('detailInfo')"></Tooltip>
            <div class="model-tips">
              (证照：<span>近效期</span>
              <span class="model-tips-nearly"></span>
            </div>
            <div class="model-tips">
              <span>过期</span>
              <span class="model-tips-expire"></span>)
            </div>
            <el-button
              style="margin-left: auto; margin-right: 10px"
              @click="preferenceInfo.visible = true"
              >偏好设置</el-button
            >
          </div>
        </div>
        <div class="model-panel">
          <div class="model-panel-body">
            <div class="flex_full_item">
              <!-- 表格 -->
              <page-table
                :refresh="tableInfo.refresh"
                :init-curpage="tableInfo.initCurpage"
                v-model:data="tableInfo.data"
                :pager="false"
                :summary="true"
                :check-box="false"
                :tab-index="true"
                :summary-field-list="tableInfo.summaryFieldList"
                :field-list="tableInfo.fieldList"
                :isDynamic="true"
                :row-class-name="tableRowClassName"
                @sortChange="sortChange"
              >
              </page-table>
            </div>
          </div>
        </div>
      </NewFullScreen>
    </div>
    <modify
      v-if="modifyInfo.visible"
      v-model:visible="modifyInfo.visible"
      :title="modifyInfo.title"
      :order-id="modifyInfo.orderId"
      :is-copy="modifyInfo.isCopy"
      @returnModify="returnModify"
    />
    <checkPurchApplication
      v-if="purchOrderCheckApplicationInfo.visible"
      v-model:visible="purchOrderCheckApplicationInfo.visible"
      :purch-application-id="purchOrderCheckApplicationInfo.orderId"
      :purch-application-info="purchOrderCheckApplicationInfo.info"
      :purch-type="purchOrderCheckApplicationInfo.purchType"
      :purch-according="purchOrderCheckApplicationInfo.purchAccording"
      :title="purchOrderCheckApplicationInfo.title"
      @returnModify="returnModify"
    />
    <TemplateModify
      v-if="templateModifyInfo.visible"
      v-model:visible="templateModifyInfo.visible"
      :purchApplicationOrderId="templateModifyInfo.purchApplicationOrderId"
      :title="templateModifyInfo.title"
    />
    <SetPreferenceNoQuery
      v-if="preferenceInfo.visible"
      v-model:visible="preferenceInfo.visible"
      :searchList="filterInfo.searchList"
      :fieldList="tableInfo.fieldList"
      :customizeUserVO="filterInfo.query.customizeUserVO"
      tableKey="purchApplicationDetail-com.slip.spd.entity.vo.purch.PurchApplicationDetailVO"
      :groupLevelShow="false"
      @callback="setPreferenceCallback"
    />
    <page-dialog
      v-if="pageDialogInfo.visible"
      :title="pageDialogInfo.title"
      v-model:visible="pageDialogInfo.visible"
      :width="pageDialogInfo.width"
      :bt-loading="pageDialogInfo.btLoading"
      :bt-list="pageDialogInfo.btList"
      @reset="closeDialog"
    >
      <page-form
        class="paddingBox order-model-formBox flex_wrap_start_start"
        v-model:ref-obj="pageFormInfo.ref"
        :data="pageFormInfo.data"
        :field-list="pageFormInfo.fieldList"
        :label-width="pageFormInfo.labelWidth"
      />
    </page-dialog>
  </div>
</template>
<script setup name="purchApplicationDetailView">
import {
  purchApplicationDetailCustomizeListAll,
  exportPurchApplication,
  getPurchApplication,
  rejectPurchApplication,
  methodPurchApplication,
  getPurchApplicationPrint,
  applicationsSubmitValidatePlanRemind
} from '@/api/purch'
import { orderAffairAll } from '@/api/affair'
import { getCustomizeSetting, updateUserCustomize } from '@/api/customize'
import modify from './modify'
import { getCoreSystemConfigAll, getReceiveAddressAll } from '@/api/core'
import { fatchTemplateByCode } from '@/api/base'
import checkPurchApplication from '@/views/purch/order/checkPurchApplication'
import { doPrint } from '@/utils/exportUtil.js'
import { selectByCodeAndDept } from '@/api/report.js'
import { updatePrintCount } from '@/api/mapping'

const TemplateModify = defineAsyncComponent(() =>
  import('../template/subscribe/modify')
)
const Tooltip = defineAsyncComponent(() => import('@/components/Tooltip/index'))
const SetPreferenceNoQuery = defineAsyncComponent(() =>
  import('@/components/SetPreference/setPreferenceNoQuery')
)

const { proxy } = getCurrentInstance()
const emit = defineEmits()
const props = defineProps(['tableRow'])
const tableKey = ref(
  'purchApplicationDetail-com.slip.spd.entity.vo.purch.PurchApplicationDetailVO'
)
const systemConfig = ref({})
const showDialog = ref(false)
const pageDialogInfo = ref({
  title: '选择采购依据',
  visible: false,
  type: '',
  width: '400px',
  row: {},
  btLoading: false,
  btList: [
    {
      label: '关闭',
      type: '',
      icon: '',
      event: closeDialog,
      show: true,
    },
    {
      label: '保存',
      type: 'primary',
      icon: '',
      event: saveDialog,
      saveLoading: false,
      show: true,
    },
  ],
})
const pageFormInfo = ref({
  ref: null,
  data: {},
  fieldList: [
    {
      label: '采购依据',
      value: 'purch_according',
      type: 'select-model',
      code: 'purch_according',
    },
  ],
})
const infoList = reactive({
  data: {},
  fieldList: [
    { label: '申购单号', value: 'orderNo', type: 'text' },
    { label: '部门', value: 'deptName', type: 'text' },
    { label: '状态', value: 'statusValue', type: 'text' },
    { label: '创建人', value: 'createUserName', type: 'text' },
    { label: '创建时间', value: 'createTime', type: 'text' },
    { label: '更新人', value: 'updateUserName', type: 'text' },
    { label: '更新时间', value: 'updateTime', type: 'text' },
    { label: '新订单号', value: 'mergedOrder', type: 'slot' },
    { label: '原订单号', value: 'mergedOrders', type: 'slot' },
    { label: '是否临采', value: 'temporaryPurchValue', type: 'text' },
    { label: '备注', value: 'remark', type: 'text' },
  ],
})
// 过滤相关配置
const filterInfo = reactive({
  sortArr: [],
  copyQueryMap: {},
  query: {
    queryMap: {
      orderId: {
        queryType: 'EQUALS',
        queryCategory: 'AND',
        value: null,
      },
    },
    queryParams: {
      deptId: null,
    },
    sortString: '',
    copyQueryMap: {},
    groupMap: {},
    groups: [],
    queryParams: {},
  },
  searchList: [],
  searchBtn: [],
  btnList: [],
})
const fullInfo = reactive({
  btnList: [],
})
// 表格相关
const tableInfo = reactive({
  summaryFieldList: [
    { value: 'qty', formatter: proxy.$fn.qtyFormatter },
    { value: 'sumAmount', formatter: proxy.$fn.TripartiteMethod },
  ],
  fieldList: [],
  refresh: 1,
  initCurpage: 1,
  api: undefined,
  data: [],
  selections: [],
})
const affairTableInfo = reactive({
  api: orderAffairAll,
  query: {
    orderType: 3,
    orderId: props.tableRow.id,
    sort: 'operate_time desc',
  },
})
const modifyInfo = reactive({
  visible: false,
  title: '',
  orderId: '',
  isCopy: false,
})
const purchOrderCheckApplicationInfo = reactive({
  visible: false,
  title: '通过申购单生成采购单',
  purchType: 0,
  orderId: null,
  info: undefined,
})
//另存为模板参数
const templateModifyInfo = reactive({
  visible: false,
  purchApplicationOrderId: '',
  title: '另存为模板',
})
const preferenceInfo = reactive({
  visible: false,
})

const canUpdate = computed(() => {
  return (
    proxy.$permission('purchApplication:update') && infoList.data.status === 1
  )
})
const canPrint = computed(() => {
  return (
    proxy.$permission('purchApplication:print') && infoList.data.status !== 1
  )
})
const canExcel = computed(() => {
  return (
    proxy.$permission('purchApplication:excel') && infoList.data.status !== 1
  )
})
const submit = computed(() => {
  return (
    proxy.$permission('purchApplication:submit') && infoList.data.status === 1
  )
})
const revoke = computed(() => {
  return (
    proxy.$permission('purchApplication:revoke') &&
    (infoList.data.status === 2 ||
      (infoList.data.status === 3 &&
        proxy.$store.state.permission.systemConfig
          .allow_purch_application_approval != 1))
  )
})
const ratify = computed(() => {
  return (
    proxy.$permission('purchApplication:ratify') && infoList.data.status === 2
  )
})
const review = computed(() => {
  return (
    proxy.$permission('purchApplication:review') && infoList.data.status === 13
  )
})
const canReturn = computed(() => {
  return (
    proxy.$permission('purchApplication:return') && infoList.data.status === 13
  )
})
const canReject = computed(() => {
  return (
    proxy.$permission('purchApplication:reject') && infoList.data.status === 2
  )
})
const canSplit = computed(() => {
  return (
    proxy.$permission('purchApplication:split') &&
    (infoList.data.status === 1 ||
      infoList.data.status === 2 ||
      infoList.data.status === 3) &&
    infoList.data.mergedOrders.length > 0 &&
    infoList.data.status === infoList.data.beforeMergeStatus
  )
})
const stop = computed(() => {
  return (
    proxy.$permission('purchApplication:stop') &&
    (infoList.data.status === 5 ||
      (infoList.data.status === 3 &&
        proxy.$store.state.permission.systemConfig
          .allow_purch_application_approval === 1))
  )
})

watch(
  () => proxy.visible,
  (value) => {
    showDialog.value = value
  },
  {
    immediate: true,
  }
)

watch(
  () => props.tableRow,
  (newVal) => {
    filterInfo.query.queryMap.orderId.value = newVal.id
    affairTableInfo.query.orderId = newVal.id
    getCustomize()
  },
  {
    immediate: true,
    deep: true,
  }
)

let obj = {
  price: {
    label: '单价',
    value: 'price',
    type: 'column',
    formatter: proxy.$fn.TripartiteMethod,
    permission: !proxy.$permission('purchApplication:price'),
    hidden: true,
  },
  sumAmount: {
    label: '总金额',
    value: 'sumAmount',
    type: 'column',
    formatter: proxy.$fn.TripartiteMethod,
    permission: !proxy.$permission('purchApplication:price'),
    hidden: true,
  },
  orderNo: {
    label: '单号',
    value: 'orderNo',
    componentType: 'input',
    show: false,
    type: 'column',
    hidden: true,
  },
  defaultSupplierPrice: {
    label: '默认供应商价格',
    value: 'defaultSupplierPrice',
    type: 'column',
    permission: !proxy.$permission('purchApplication:price'),
    formatter: proxy.$fn.TripartiteMethod,
    hidden: true,
  },
  userDefaultDepotStockQty: {
    label: '用户默认仓库库存量',
    value: 'userDefaultDepotStockQty',
    type: 'column',
    show: false,
    hidden: true,
  },
  beforeExportQty: {
    label: '上月出库量',
    value: 'beforeExportQty',
    type: 'column',
    show: false,
    hidden: true,
  },
}
tableInfo.fieldList = Object.values({
  ...proxy.$fn.deepClone(proxy.$fieldfList.FieldList),
  ...proxy.$fn.deepClone(obj),
})
console.log(tableInfo.fieldList)

function setPreferenceCallback(obj) {
  updateUserCustomize(obj.customizeUserVO).then((res) => {
    if (res && res.success) {
      getCustomize()
    }
  })
}
function closeDialog() {
  pageDialogInfo.value.visible = false
  pageFormInfo.value.data = {}
}

//拷贝
function copyApplicationOrder() {
  modifyInfo.visible = true
  modifyInfo.isCopy = true
  modifyInfo.title = '拷贝申购单'
  modifyInfo.orderId = props.tableRow.id
}
//另存为模板
function saveCopeTemplate() {
  templateModifyInfo.visible = true
  templateModifyInfo.purchApplicationOrderId = props.tableRow.id
}
function returnModify() {
  if (props.tableRow.id) {
    getCustomize()
  }
}

function handleClick(method) {
  const row = props.tableRow
  const ids = getSelectionIds(row)
  if (method === 'reject') {
    proxy
      .$prompt('请输入驳回理由', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputValidator: proxy.$fn.maxString200,
        inputErrorMessage: '驳回理由不能超过200字符',
      })
      .then(({ value }) => {
        const data = {
          id: row.id,
          rejectReason: value,
        }
        methodPurchApplication(data, method).then((resp) => {
          if (resp && resp.success) {
            getCustomize()
          }
        })
      })
  } else if (method === 'return') {
    proxy
      .$prompt('请输入退回理由', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputValidator: proxy.$fn.isNotEmptyString,
        inputErrorMessage: '请输入退回理由并不超过200字符',
      })
      .then(({ value }) => {
        const data = {
          id: row.id,
          returnReason: value,
        }
        methodPurchApplication(data, method).then((resp) => {
          if (resp && resp.success) {
            getCustomize()
          }
        })
      })
  } else if (method === 'stop') {
    proxy
      .$confirm('中止后单据将变为已中止状态，是否继续中止？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then(() => {
        methodPurchApplication(ids, method).then((resp) => {
          if (resp.success) {
            getCustomize()
          }
        })
      })
  } if(method ==='submit'){
    applicationsSubmitValidatePlanRemind(ids).then(res => {
      if(res && res.success){
        methodPurchApplication(ids, method).then((resp) => {
          if (resp.success) {
            getCustomize()
          }
        })
      }
    })
  } else {
    methodPurchApplication(ids, method).then((resp) => {
      if (resp.success) {
        getCustomize()
      }
    })
  }
}
function getSelectionIds(row = undefined) {
  let ids = []
  if (row) {
    ids.push(row.id)
  } else {
    ids = tableInfo.selections.map(function (item) {
      return item.id
    })
  }
  return ids
}

function returnBack() {
  emit('update:visible', false)
  emit('returnBack', false)
}
function getList() {
  purchApplicationDetailCustomizeListAll(filterInfo.query).then((resp) => {
    if (resp && resp.success) {
      tableInfo.data = resp.data
    }
  })
}

function getMain(id) {
  getPurchApplication(id).then((resp) => {
    if (resp && resp.success) {
      infoList['data'] = resp.data
      filterInfo.query.queryParams.deptId = infoList.data.deptId
      getList()
    }
  })
}
// 编辑
function update() {
  modifyInfo.visible = true
  modifyInfo.title = '修改申购单'
  modifyInfo.orderId = props.tableRow.id
}
//导出excel
function exportExcel() {
  exportPurchApplication(filterInfo.query).then((resp) => {
    if (resp) {
      proxy.$fn.parseExcel(resp)
    }
  })
}
const templateArr = ref([])
const popoverVisible = ref(false)
//打印
function print() {
  selectByCodeAndDept({
    tempCode: 'purchApplication',
    deptId: infoList.data.deptId,
  }).then((res) => {
    if (res && res.success) {
      templateArr.value = res.data
      popoverVisible.value = true
      // 一条数据则直接打印
      if (templateArr.value.length === 1) {
        proxy.$refs.popoverShow.hidePopover()
        doPrint({
          name: templateArr.value[0].ureportName,
          params: {
            applicationId: props.tableRow.id,
            orderId: props.tableRow.id,
            orderNo: props.tableRow.orderNo,
          },
          callback: printCallback,
          printCount: true,
          data: {},
        })
      }
    }
  })
  // return
  // fatchTemplateByCode({
  //   resourceCode: 'purchApplication:print',
  //   isDefault: 1,
  // }).then((res) => {
  //   if (res && res.success) {
  //     let temp = proxy.$fn.getPrintTemp(res.data[0])
  //     getPirntData(temp)
  //   }
  // })
}
function tempClick(item) {
  doPrint({
    name: item.ureportName,
    params: {
      applicationId: props.tableRow.id,
      orderId: props.tableRow.id,
      orderNo: props.tableRow.orderNo,
    },
    callback: printCallback,
    printCount: true,
    data: {},
  })
  popoverVisible.value = false
}
function printCallback() {
  try {
    // 打印成功增加打印次数
    updatePrintCount({
      orderNo: infoList.data.orderNo,
      tempCode: 'purchApplication',
      orderId: infoList.data.id,
      orderType: 3,
    })
  } catch (error) {}
}
function getPirntData(temp) {
  let params = {
    tableKey:
      'purchApplicationDetail-com.slip.spd.entity.vo.purch.PurchApplicationDetailVO',
    orderIds: [props.tableRow.id],
  }
  getPurchApplicationPrint(params).then((res) => {
    if (res.success && res) {
      let data = proxy.$fn.deepClone(res.data)
      let newData = data.map((item) => {
        return {
          ...item,
          ...item.orderInfo,
        }
      })
      proxy.$lodop.preview(
        temp,
        newData,
        !proxy.$permission('purchApplication:price')
      )
    }
  })
}

function getValueList() {
  getCoreSystemConfigAll().then((resp) => {
    if (resp && resp.success) {
      const data = {}
      resp.data.forEach((item) => {
        data[item.systemConfigCode] = item.value
      })
      systemConfig.value = data
    }
  })
}
function tableRowClassName({ row = undefined }) {
  if (row.licenseEndDate) {
    let dataDiff = proxy.$fn.dateDiff(new Date(), row.licenseEndDate)
    if (dataDiff <= 0) {
      return 'expire-row'
    } else if (
      Number(systemConfig.value.license_nearly_effective) >=
      dataDiff >
      0
    ) {
      return 'nearly-row'
    }
  }
  return ''
}
function handelMethodRequest(method) {
  const ids = []
  ids.push(props.tableRow.id)
  methodPurchApplication(ids, method).then((resp) => {
    if (resp.success) {
      showDialog.value = false
      emit('returnBack', false)
    }
  })
}
//驳回
function reject() {
  proxy
    .$prompt('请输入驳回理由', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      inputValidator: proxy.$fn.maxString200,
      inputErrorMessage: '驳回理由不能超过200字符',
    })
    .then(({ value }) => {
      const data = {
        id: props.tableRow.id,
        rejectReason: value,
      }
      rejectPurchApplication(data).then((resp) => {
        if (resp && resp.success) {
          showDialog.value = false
          emit('returnBack', false)
        }
      })
    })
}
function handelGeneratePurch() {
  if (
    proxy.$store.state.permission.systemConfig.purch_according != '1' &&
    proxy.$store.state.permission.systemConfig.purch_according != '2'
  ) {
    pageDialogInfo.value.visible = true
  } else {
    const params = {
      isDefault: '1',
    }
    getReceiveAddressAll(params).then((resp) => {
      if (resp && resp.success) {
        purchOrderCheckApplicationInfo.visible = true
        purchOrderCheckApplicationInfo.orderId = infoList.data.id
        purchOrderCheckApplicationInfo.info = infoList.data
        purchOrderCheckApplicationInfo.purchAccording =
          proxy.$store.state.permission.systemConfig.purch_according
      }
    })
  }
}
function saveDialog() {
  if (pageFormInfo.value.data.purch_according) {
    const params = {
      isDefault: '1',
    }
    getReceiveAddressAll(params).then((resp) => {
      if (resp && resp.success) {
        purchOrderCheckApplicationInfo.orderId = infoList.data.id
        purchOrderCheckApplicationInfo.info = infoList.data
        purchOrderCheckApplicationInfo.purchAccording =
          pageFormInfo.value.data.purch_according
        closeDialog()
        proxy.$nextTick(() => {
          purchOrderCheckApplicationInfo.visible = true
        })
      }
    })
    return
  } else {
    proxy.$message.warning('请选择采购依据')
  }
}

function sortChange(column) {
  if (filterInfo.query.customizeUserVO.head.sortType === 0) {
    let arr = proxy.$fn.sortChange(column, filterInfo.sortArr)
    filterInfo.sortArr = arr
    filterInfo.query.sortString = arr.length ? arr.toString() : ''
    getList()
  }
}
function getNew(id) {
  filterInfo.query.queryMap.orderId.value = id
  affairTableInfo.query.orderId = id
  getMain(id)
}
function handleCommand(id) {
  getNew(id)
}
function getCustomize() {
  let param = {
    tableKey: tableKey.value,
  }
  getCustomizeSetting(param).then((res) => {
    if (res && res.success) {
      let data = res.data
      tableInfo.fieldList = proxy.$fn.setFieldList(
        tableInfo.fieldList,
        data.detail
      )
      console.log(tableInfo.fieldList)
      filterInfo.query.customizeUserVO = data
      filterInfo.query.queryMap.orderId.value = props.tableRow.id
      tableInfo.api = purchApplicationDetailCustomizeListAll
      getValueList()
      getMain(props.tableRow.id)
    }
  })
}
</script>

<style scoped lang="scss">
:deep(.page-table > .el-table) {
  overflow-y: hidden;
}
.model-panel-title {
  display: flex;
  align-items: center;

  .model-tips {
    display: flex;
    align-items: center;
    margin-left: 10px;
    color: #909399;

    .model-tips-nearly,
    .model-tips-expire {
      display: block;
      margin-left: 5px;
      width: 17px;
      height: 17px;
    }

    .model-tips-nearly {
      background: #fceacb;
    }

    .model-tips-expire {
      background: #f5e4e4;
    }
  }
}
:deep(.el-table .nearly-row) {
  background: #fceacb;
}
:deep(.el-table .expire-row) {
  background: #f5e4e4;
}
// :deep(.el-table__body tr.hover-row > td) {
//   background-color: transparent !important;
// }
</style>
